package com.git.bds.mr.hospital.controller;

import com.git.bds.mr.doctor.model.dto.DoctorInfoDTO;
import com.git.bds.mr.hospital.model.vo.HospitalDoctorVO;
import com.git.bds.mr.hospital.service.hospital.HospitalService;
import com.git.bds.mr.page.PageParam;
import com.git.bds.mr.page.PageResult;
import com.git.bds.mr.result.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 成大事
 * @since 2022/9/19 18:38
 */
@Api(tags = "医院 管理")
@Slf4j
@Validated
@RestController
@RequestMapping("/hospital/sector/doctor")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class HospitalDoctorController {

    private final HospitalService hospitalService;

    @PostMapping("/addDoctor")
    @ApiOperation("医院添加 新入职医生")
    public R<Boolean> addDoctor(
            @Validated @RequestBody DoctorInfoDTO doctorInfoDTO
    ){
        return R.decide(hospitalService.addDoctor(doctorInfoDTO));
    }

    @PostMapping("/modifyDoctor")
    @ApiOperation("医院修改医生信息")
    public R<Boolean> modifyDoctor(
            @Validated @RequestBody DoctorInfoDTO doctorInfoDTO
    ){
        return R.decide(hospitalService.modifyDoctor(doctorInfoDTO));
    }

    /**
     * 请所有医生
     *
     * @param pageParam 页面参数
     * @return {@link R}<{@link PageResult}<{@link HospitalDoctorVO}>>
     */
    @PostMapping("/getAllDoctors")
    @ApiOperation("医院 获取医院的所有医生")
    public R<PageResult<HospitalDoctorVO>> getAllDoctors(
            @Validated @RequestBody PageParam pageParam
    ){
        return R.ok(hospitalService.getAllDoctors(pageParam));
    }









}
